package com.itheima.cold.netty;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class NettyBooter implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private JobNettyServer jobNettyServer;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        System.out.println("onApplicationEvent");
        jobNettyServer.start();
//        if(event.getApplicationContext().getParent()==null) {
//            try {
//                jobNettyServer.start();
//                System.out.println("启动Netty服务器！");
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
    }
}
